/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.utl.ist.isr.livetrack.tracker.mht.events;

import eu.anorien.mhl.Event;
import org.apache.log4j.Logger;
import pt.utl.ist.isr.livetrack.server.interfaces.Zone;
import pt.utl.ist.isr.livetrack.tracker.Entity;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class TargetInEvent<TargetInfo> implements Event {

    private static final Logger logger = Logger.getLogger(TargetInEvent.class);
    private final long timestamp;
    private final Entity entity;
    private final Zone zone;
    private final TargetInfo entityInformation;

    public TargetInEvent(long timestamp, Entity entity, Zone zone, TargetInfo entityInformation) {
        this.timestamp = timestamp;
        this.entity = entity;
        this.zone = zone;
        this.entityInformation = entityInformation;
    }

    public Entity getEntity() {
        return entity;
    }

    public TargetInfo getTargetInfo() {
        return entityInformation;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public Zone getZone() {
        return zone;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final TargetInEvent<TargetInfo> other = (TargetInEvent<TargetInfo>) obj;
        if (this.timestamp != other.timestamp) {
            return false;
        }
        if (this.entity != other.entity && (this.entity == null || !this.entity.equals(other.entity))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (int) (this.timestamp ^ (this.timestamp >>> 32));
        hash = 59 * hash + (this.entity != null ? this.entity.hashCode() : 0);
        return hash;
    }
}
